<template>
	<view class="caiwu">
		<view class="listWrapper">
			<view v-for="item in dataList" class="item" v-on:click="onItem(item)" :class="{alipay:item.Bankname=='支付宝'}">
				<view class="name">{{item.Bankname}}</view>
				<view class="type">{{item.Name}}</view>
				<view class="number">{{item.cc}}</view>
			</view>
			<view class="add" v-on:click="onAdd">
				<image src="../../static/jiahao.png"></image>
				<view class="name">添加银行卡</view>
			</view>
			<view class="add" v-on:click="onAlipay">
				<image src="../../static/jiahao.png"></image>
				<view class="name">添加支付宝账号</view>
			</view>
		</view>
	</view>
</template>

<script>
	import http from '../../common/http.js';
	import common from '../../common/common.js';
	export default {
		data() {
			return {
				lastid:0,
				noMore:false,
				isLoadingMore:false,
				dataList:[""],
				storeid:'',
				from:''
			}
		},
		onLoad(options) {
			this.storeid = options.storeid
			this.from = options.from
			
			if (this.from == "tixian") {
				uni.setNavigationBarTitle({
					title:"点击选择到账账户"
				})
			}
		},
		onShow() {
			this.refreshData()
		},
		methods: {
			refreshData(){
				var self = this
				http.get("/store/finance", {"lastid":self.lastid, "storeid":this.storeid}, (res)=>{
					for (var i=0;i<res.length;i++) {
						var item = res[i]
						if (item["Type"] == 1) {
							item["cc"] = common.splitBank(item["Code"])
						}else{
							item["cc"] = item["Code"]
						}
						
					}
					self.dataList = res
				})
			},
			onAdd() {
				uni.navigateTo({
					url:"../bankadd/bankadd"
				})
			},
			onAlipay() {
				uni.navigateTo({
					url:"../alipayadd/alipayadd"
				})
			},
			onItem(e) {
				console.log(e)
				if (this.from == "tixian") {
					uni.setStorageSync("toaccount",e)
					wx.navigateBack()
				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #f3f3f2;
		padding-bottom: 40px;
	}
	
	.item {
		background-image: url(../../static/yinhangka.png);
		background-size: 100% 100%;
		border-radius: 4px;
		margin: 10px 10px;
		color: rgba(255,255,255, 0.8);
		padding: 10px;
		box-sizing: border-box;
		position: relative;
	}
	.alipay {
		background-image: url(../../static/zhifubao.png);
	}
	.item image {
		width: 100%;
		height: 100%;
	}
	.name {
		font-size: 18px;
		font-weight: 400;
	}
	.type {
		margin-top: 5px;
	}
	.number {
		margin-top: 10px;
		color: #DEDEDE;
	}
	.add {
		background-color: white;
		height: 70px;
		display: flex;
		align-items: center;
		padding: 0 15px;
		margin: 10px;
		border-radius: 4px;
	}
	.add image {
		width: 20px;
		height: 20px;
		margin-right: 10px;
		
	}
	.add .name {
		font-size: 18px;
	}
</style>
